package dimensional.traveler.server.services.servlets;

import java.util.HashMap;
import java.util.Map;

import com.google.inject.Inject;

import dimensional.traveler.client.services.CareerService;
import dimensional.traveler.client.services.MenuImageService;
import dimensional.traveler.client.services.ServiceAggregator;
import dimensional.traveler.client.services.UserService;
import dimensional.traveler.server.services.servlets.base.ServiceServletBaseWithDummyMethod;
import dimensional.traveler.shared.Settings;

public class ServiceAggregatorImpl extends ServiceServletBaseWithDummyMethod implements ServiceAggregator {

	private static final long serialVersionUID = -7928851212456802026L;

	@Inject
	private MenuImageService menuImageService;
	@Inject
	private UserService userService;
	@Inject
	CareerService careerService;
	
	@Override
	public Map<String, Object> getMenuImagesAndSaveGameInfoForUser(String userName) {
		Map<String, Object> aggregatedResult = new HashMap<>();
		
		aggregatedResult.put(Settings.IMAGE_PATHS_KEY, menuImageService.getMenuImagePaths());
		aggregatedResult.put(Settings.SAVE_GAME_INFO_KEY, userService.getSaveGameInfoForUser(userName));
		
		return aggregatedResult;
	}

	@Override
	public Map<String, Object> getGameMenuData(String userName) {
		Map<String, Object> aggregatedResult = new HashMap<>();
		
		aggregatedResult.put(Settings.NEW_MISSIONS_KEY, careerService.getNewMissions(userName));
		aggregatedResult.put(Settings.OLD_MISSIONS_KEY, careerService.getReplayableMissions(userName));
		
		return aggregatedResult;
	}

}
